import router from '../router/index'

import axios from './axios';
const domain='http://jingda.luckread.cn/api/';
axios.defaults.baseURL=domain;
axios.interceptors.response.use(function (response) { 
  // 重定向到登录页面 
  if (response.data.data == 'no_login'){
    window.localStorage.removeItem('user_name');
    router.replace({ path: '/login'}) 
  }else{
    return response;
  }
})
    //获取活动详情
    export const getActivityInfo = (params) => axios.get('activity/getActivityInfo',{'params':{...params}});
    //报名
    export const activitySignUp = (params) => axios.post('activity/activitySignUp',params);
    //上传头像(文件上传)
    export const uploadImg = (params) => axios.post('file/upload-img',params,{headers:{'Content-Type':'multipart/form-data'}});
    //获取答卷列表
    export const getAnswerSheetList = (params) => axios.get('answer/getAnswerSheetList',{'params':{...params}});
    //获取题目列表
    export const getQuestionsList = (params) => axios.get('answer/getQuestionsList',{'params':{...params}});
    //逐题保存题目
    export const answerAction = (params) => axios.post('answer/answerAction',params);
    //保存题目
    export const submitAnswer = (params) => axios.post('answer/submitAnswer',params);

  // 排行榜
    //获取答卷详情
    export const getUserQuestionAnswer = (params) => axios.get('admin/sys/getUserQuestionAnswer', {'params':{...params}});
    //获取排行榜列表
    export const getLeaderBoard = (params) => axios.get('answer/getLeaderBoard', {'params':{...params}});
    
    
    
    
    
    
    

    